
<?=	form_open_multipart('admin/products/save'); ?>
<?php
 if (isset($success)){ 
    ?>
    <div class="success">
    	<ul>
    <?=trim($success)?>
        </ul>
    </div>
<?php }?>
<?php
 if (isset($error)){ 
    ?>
    <div class="error">
    	<ul>
    <?=trim($error)?>
        </ul>
    </div>
<?php }?>
<?= form_hidden('productId',isset($productId)?$productId:'') ?>
<table style="margin-left: auto;margin-right: auto;">	
	<tr >
	    <td>
	    	Категория
	    	<span class="required">*</span>
	    </td>
		<td>
		<?=$categories?>
	    </td>
	   </tr>
	 <tr>
	   	<td>
	    	Име
	    	<span class="required">*</span>
	    </td>
	   	<td>
	   		<input type="text" name="title" 
	   		value="<?=isset($product['title'])?$product['title']:''?>" size="85" />
	   	</td>
	   </tr>
	   <tr>
	   	<td>
	    	Описание
	    </td>
	   	<td>
	   		<textarea name="description"  id="description"  cols="38" rows="10" ><?=isset($product['description'])?trim($product['description']):''?></textarea>
	   		<?php echo display_ckeditor($ckeditor); ?>
	   	</td>
	   </tr>
	   <tr>
	    <td>
	    	Производител
	    </td>
	   	<td>
	   		<input type="text" name="company" 
	   		value="<?=isset($product['company'])?$product['company']:''?>" size="85" />
	   	</td>
	   </tr>
	   <tr>
	    <td>
	    	Връзка
	    </td>
	   	<td>
	   		<input type="text" name="link" 
	   		value="<?=isset($product['link'])?$product['link']:''?>" size="85" />
	   	</td>
	   </tr>
	   <tr>
	   	<td>
	   		Промоция
	   	</td>
	   <td>
	   		
	   <?=form_checkbox('s_promotion', '1', 
		(isset($product['is_promotion'])&& !empty($product['is_promotion']))?TRUE:FALSE
		);?>		
	   </td>
	</tr>
	<tr>
		<td colspan="2">
			<div id="gallery">
		<?php if (isset($images) && count($images)):
			foreach($images as $image):	?>
			
			<div class="thumb">
				<div class="removeBox">
					
                    <a href="<?= site_url('admin/products/removePic/'.$image['name'].'/'.$productId)?>">Изтрии
       	   			<img border="0" title="Изтриване" alt="Изтриване" src="<?= base_url() ?>images/delete.png">
        	   		</a>
            	</div>
				<a href="<?php echo $image['url']; ?>">
					<img src="<?php echo $image['thumb_url']; ?>" />
				</a>
				<div class="color">
				    <?= isset($image['color'])?$image['color']:'' ?>
				</div>				
			</div>
			
		<?php endforeach; else: ?>
			<div id="blank_gallery">Please Upload an Image</div>
		<?php endif; ?>
	</div>
	
	   <?php if (isset($productId)) {?>
    	<table id="upload">
    	<tr>
    	  <td  style="vertical-align:middle;">Цвят
    		<span class="required">*</span></td>
    	  <td style="vertical-align:middle;"><input type="text" name="color" value="" style="margin-right: 10px;"/></td>
    	  <td style="vertical-align:middle;">	<?php
    	
    		$attr=array('name' => 'userfile');
    		echo form_upload($attr);
    		?>
    	    </td>
    	    <td style="vertical-align:middle;">
    	    	<?php
    	    	$attr=array('name' => 'upload',
    		            'value'=>'Attach picture',
        				'style' => 'height: 25px;margin-left:10px;');
    		echo form_submit($attr);
    		
    		?>
    	    </td>
    	</tr>
    	</table>
	   <?php } ?>
		</td>
	</tr>  
	<tr>
		<td colspan="2" style="text-align: center;">
			<hr style="margin-bottom: 5px;">
			<?= form_submit('save', 'Запис');?>
			<hr style="margin-top: 5px;">
		</td>
	</tr>
</table>
<?= form_close(); ?>
</tbody>
</table>
